Switch to Gitea incluster repository provider for e2e tests#27
Merged
creydr merged 19 commits intofunctions-dev:mainfrom Mar 16, 2026
Merged
Switch to Gitea incluster repository provider for e2e tests#27creydr merged 19 commits intofunctions-dev:mainfrom
creydr merged 19 commits intofunctions-dev:mainfrom
Conversation
- Configure Gitea with NodePort on ports 30000 (HTTP) and 30022 (SSH) - Set admin credentials for test usage - Create ConfigMap with Gitea endpoint for test discovery - Disable persistence for ephemeral test environment
- Implement NewGiteaClient() that discovers Gitea endpoint from ConfigMap - Create Gitea SDK client with admin authentication - Add Gitea SDK dependency to go.mod
- Define RepositoryProvider interface for git server operations - Allows switching between Gitea/GitHub/GitLab without test code changes - GiteaClient will implement this interface
- Implement CreateUser() for creating users with specific credentials - Implement DeleteUser() for cleanup - Implement CreateRandomUser() for test isolation - GiteaClient now partially implements RepositoryProvider interface
- Implement CreateRepo() for creating repositories - Implement DeleteRepo() for cleanup - Implement CreateRandomRepo() for test isolation - Build and return repository URLs automatically
- Implement CreateAccessToken() for generating user tokens - Support authentication for private repositories - GiteaClient now fully implements RepositoryProvider interface
- Add buildAuthURL() for embedding credentials in git URLs - Add InitializeRepoWithFunction() for setting up function repos - Add CommitAndPush() for flexible commit/push with proper error handling - Helpers simplify test code and promote reusability
- Add repoProvider variable using RepositoryProvider interface - Initialize with GiteaClient in BeforeSuite - Verify provider is not nil before tests run - Interface allows easy switching to other providers
- Replace GitHub cloning with RepositoryProvider workflow in BeforeEach - Use InitializeRepoWithFunction() helper for repo setup - Update Function specs to use repository provider URLs - Add proper cleanup of repository resources in AfterEach - Tests now isolated and independent of external GitHub - Keep abstraction by using generic terminology
- Update RepositoryProvider interface to return cleanup functions - Implement cleanup functions in CreateUser, CreateRepo, etc. - Use Ginkgo's DeferCleanup for automatic cleanup in tests - Simplify AfterEach blocks to only handle failure logging - Much cleaner and less error-prone test code
- Update helper functions to accept and use repoURL parameter - Replace GitHub URLs with RepositoryProvider workflow in setup functions - Track repoURLs alongside namespaces for all tests - Use DeferCleanup for automatic resource cleanup - Tests now use in-cluster repository provider for all git operations - Remove unused rand import
- Define TestNamespace struct with Name and RepoURL fields - Replace separate namespace and repoURL slices with single slice - Update all functions to accept/return TestNamespace - Prevents misalignment of parallel slices - Much safer and cleaner API
- Comprehensive guide for using RepositoryProvider in tests - Document test patterns and helper methods - Explain DeferCleanup pattern for automatic cleanup - Add troubleshooting section - Describe implementation details and architecture - Update README with Gitea test information
Fixes multiple issues preventing e2e tests from running with in-cluster Gitea instead of external GitHub: - Set MustChangePassword to false when creating users to prevent auth errors - Use AdminCreateRepo to create repos under correct user account - Rewrite function initialization to avoid git/func init conflicts - Add git user configuration for commits - Use main branch instead of master for modern git compatibility - Improve error messages by using utils.Run for all git commands - Add function code to "not yet deployed" test scenario
In CI environments, git may not have a default branch name configured, causing 'git init' to create a branch with a different name (e.g., master). This causes the subsequent 'git push -u origin main' to fail with 'src refspec main does not match any'. Use 'git init -b main' to explicitly create the main branch, ensuring consistent behavior across all environments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using Gitea as a Git repository provider for e2e tests to remove dependency to presetup Git repositories on Github